{include file="public/layout" /}
{include file="gzh/header" /}

<body class="bodystyle" style="overflow-y: scroll; cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
{include file="canal/left" /}
<div class="page min-hg-c-10" style="min-width:auto;margin-left:100px;">

{include file="gzh/reply_bar" /}
    <form class="form-horizontal" id="post_form" action="" method="post" enctype="multipart/form-data">
        <div class="ncap-form-default">
            <dl class="row">
                <dt class="tit">
                    <label for="title"><em>*</em>回复类型</label>
                </dt>
                <dd class="opt"> 
                    <label><input type="radio" name="type" value="LINK" {if condition="empty($info.type) || 'LINK' == $info.type "} checked="checked" {/if}>链接</label>&nbsp;&nbsp;
                    <label><input type="radio" name="type" value="TEXT" {if condition="!empty($info.type) && 'TEXT' == $info.type "} checked="checked" {/if}>文字</label>&nbsp;&nbsp;
                    <label><input type="radio" name="type" value="PIC" {if condition="!empty($info.type) && 'PIC' == $info.type "} checked="checked" {/if}>图文</label>&nbsp;&nbsp;
                    <label><input type="radio" name="type" value="ARC" {if condition="!empty($info.type) && 'ARC' == $info.type "} checked="checked" {/if}>站内文档</label>&nbsp;&nbsp;
                    <span class="err"></span>
                    <p class="notic"></p>
                </dd>
            </dl>
            <dl class="row dl_row" id="dl_LINK">
              <dt class="tit">
                  <label for="text"><em>*</em>链接内容</label>
              </dt>
              <dd class="opt ui-text">
                  <input name="link" placeholder="http://" value="{$info.link}" class="input-txt" type="text">
                  <p class="notic">（<span class="ui-textTips">还可以输入600个字</span>）</p>
              </dd>
            </dl>

            <dl class="row dl_row" id="dl_TEXT" style="display: none">
                <dt class="tit">
                    <label for="text"><em>*</em>文本内容</label>
                </dt>
                <dd class="opt ui-text">
                    <a href="JavaScript:void(0);" data-href=" {:url('Gzh/selcet_material_list',['type'=>1])}" onclick="openFullframe(this, '选择素材', '80%', '80%');" class="ncap-btn ncap-btn-green">选择素材</a>
                    <p class="notic">可选择文字素材或者直接写入</p>
                    <div style="padding-top: 10px;">
                        <textarea rows="5" cols="80" id="text" name="text" style="height:200px;" placeholder="请输入内容" class="ui-input" data-num="600">{$info.text}</textarea>
                    </div>
                </dd>
            </dl>

            <dl class="row dl_row" id="dl_PIC" style="display: none">
                <dt class="tit">
                    <label><em>*</em>图文内容</label>
                </dt>
                <dd class="opt">
                    <a href="JavaScript:void(0);" data-href=" {:url('Gzh/selcet_material_list',['type'=>2])}" onclick="openFullframe(this, '选择素材', '80%', '80%');" class="ncap-btn ncap-btn-green">选择素材</a>
                    <!-- 选择素材后显示-开始 -->
                    <div class="ey-pro-goods mt20 pic_class " {neq name='$info.type' value='PIC'} style="display: none;" {/neq}>
                        <input type="hidden" name="material_id" id="material_id" value="{$info.material_id}">
                        <div class="image">
                            <img id="material_litpic" width="60" height="60" src="{$info.litpic}">
                        </div>
                        <div class="content" id="material_title">{$info.title}</div>
                    </div>
                    <!-- 选择素材后显示-结束 -->
                    <span class="err"></span>
                    <p class="notic"></p>
                </dd>
            </dl>

            <dl class="row dl_row" id="dl_ARC" style="display: none">
                <dt class="tit">
                    <label><em>*</em>选择文档</label>
                </dt>
                <dd class="opt">
                    <a href="JavaScript:void(0);" data-href=" {:url('Gzh/selcet_arc_list')}" onclick="openFullframe(this, '选择文档', '80%', '80%');" class="ncap-btn ncap-btn-green">选择文档</a>
                    <div class="ey-pro-goods mt20 arc_class " {neq name='$info.type' value='ARC'} style="display: none;" {/neq}>
                        <input type="hidden" name="aid" id="aid" value="{$info.aid}">
                        <div class="image"><img width="60" height="60" src="{$info.litpic}"></div>
                        <div class="content">{$info.title}</div>
                    </div>
                    <span class="err"></span>
                    <p class="notic"></p>
                </dd>
            </dl>
            <div class="bot mt30">
                <input type="hidden" name="keyword" value="default">
                <a href="JavaScript:void(0);" onclick="formSubmit();" class="ncap-btn-big ncap-btn-green" id="submitBtn">保存</a>
            </div>
        </div>
    </form>
</div>

<script type="text/javascript">
    // 判断输入框是否为空
    function formSubmit(){
        var url = " {:url('Gzh/reply_default')}";
        layer_loading('正在处理');
        $.ajax({
            type: 'POST',
            url: url,
            data: $("#post_form").serialize(),
            dataType: 'json',
            success: function(res) {
                layer.closeAll();
                if (res.code == 1) {
                    layer.msg(res.msg, {icon: 1, time:1000}, function(){
                        location.reload();
                    });
                } else {
                    layer.msg(res.msg, {icon: 5});
                }
            },
            error:function (e) {
                layer.closeAll();
                layer.alert(e.responseText);
            }
        });
    }

    $(document).ready(function() {  
        $('input[type="radio"][name="type"]').change(function() {
            $('.dl_row').hide();// 隐藏所有dl元素

            var value = $(this).val();
            $('#dl_' + value).show(); // 显示当前元素
        });  
          
        // 初始化时，如果有默认值被选中，也执行一次change事件的处理逻辑  
        $('input[type="radio"][name="type"]:checked').trigger('change');  
    });

    function selected(obj,type) {
        $(".ey-pro-goods").hide();
        if ('TEXT' == type){
            var intro = $(obj).data('intro');
            $("#text").val(intro);
        } else if ('PIC' == type) {
            var id = $(obj).data('id');
            var litpic = $(obj).data('litpic');
            var title = $(obj).data('title');
            $("#material_id").val(id);
            $("#material_litpic").attr('src',litpic);
            $("#material_title").html(title);
            $(".pic_class").show();
        } else if ('ARC' == type) {
            var aid = $(obj).data('aid');
            var litpic = $(obj).data('litpic');
            var title = $(obj).data('title');
            $("#aid").val(aid);
            $("#material_litpic").attr('src',litpic);
            $("#material_title").html(title);
            $(".arc_class").show();
        }
        layer.closeAll();
    }
</script>
{include file="public/footer" /}